<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>画布缩放</title>
</head>
<body>
  <style>
     body{
      margin: 0;
      padding: 0;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      }
    .container {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    #canvas {
      width: 500px;
      height: 500px;
      border: 2px solid green;
    }
  </style>
  <!-- <canvas id="canvas" style="width: 500px; height: 500px;"></canvas> -->
  <div class="container">
    <canvas id="canvas" width="500px" height="500px"></canvas>
  </div>
  <script src="./index.js"></script>
</body>
</html>